/* Includes */
/* -------- */
#include "HALInputs.h"



/**************************************************************
 *  Name                 :	Get_LightingSelector_State
 *  Description          :  Return the state of LightingSelector
 *  Parameters           :  none
 *  Return               :	E_SM_LIGHTSEL_ST
 *  Critical/explanation :  No
 **************************************************************/
  E_SM_LIGHTSEL_ST Get_LightingSelector_State (void)
 {	
	T_UWORD luw_ADC_LS;
	E_SM_LIGHTSEL_ST le_adc_lsvalue;
	while (!(ADCConvertionComplete())) {};
	luw_ADC_LS = ADCReadValue(ANS_1);
	if (luw_ADC_LS >= LSP1)
	{	
		le_adc_lsvalue = LS_OFF;
	}
	else if (luw_ADC_LS >= LSP1)
	{
		le_adc_lsvalue = LS_DAYLIGHT;
	}
	else if (luw_ADC_LS >= LSP1)
	{
		le_adc_lsvalue = LS_ON;
	}
	else if (luw_ADC_LS >= LSP1)
	{
		le_adc_lsvalue = LS_AUTO;
	}
	else
	{
	}
	return le_adc_lsvalue;
 }
 
 /**************************************************************
 *  Name                 :	Get_AmbientLightSelector_State
 *  Description          :  Return the state of AmbientLightSelector
 *  Parameters           :  none
 *  Return               :	E_SM_AMBIENTLS_ST
 *  Critical/explanation :  No
 **************************************************************/
  E_SM_AMBIENTLS_ST Get_AmbientLightSelector_State (void)
 {
	T_UWORD luw_ADC_ALS;
	E_SM_AMBIENTLS_ST le_adc_alsvalue;
	while (!(ADCConvertionComplete())) {};
	luw_ADC_ALS = ADCReadValue(ANS_2);
	if (luw_ADC_ALS <= ALSF)
	{	
		le_adc_alsvalue = ALS_OFF;
	}
	else if (luw_ADC_ALS >= ALSS )
	{
		le_adc_alsvalue = ALS_HALF;
	}
	else if (luw_ADC_ALS >= ALSE)
	{
		le_adc_alsvalue = ALS_ON;
	}
	else
	{
	}
	return le_adc_alsvalue;
 }
  
 /**************************************************************
 *  Name                 :	Get_LeftTurnButton_State
 *  Description          :  Return the state of LeftTurnButton
 *  Parameters           :  none
 *  Return               :	E_SM_INPUTS_ST
 *  Critical/explanation :  No
 **************************************************************/
  E_SM_INPUTS_ST Get_LeftTurnButton_State (void)
 {
	static T_UBYTE lub_counter_LeftTurnButton = 0;
	E_SM_INPUTS_ST le_dbnc_LeftTurnButton;
	if(ZERO != IO_PinRead(LeftTurnButton))
	{
		lub_counter_LeftTurnButton ++;
		if(lub_counter_LeftTurnButton >= value_set_for_dbnc)
		{
			le_dbnc_LeftTurnButton = VALID;
		}
		else
		{
			le_dbnc_LeftTurnButton = INVALID;
		}
	}
	else
	{
		lub_counter_LeftTurnButton = 0;
		le_dbnc_LeftTurnButton = INVALID;
	}
	return le_dbnc_LeftTurnButton;
 }
  
 /**************************************************************
 *  Name                 :	Get_RightTurnButton_State
 *  Description          :  Return the state of RightTurnButton
 *  Parameters           :  none
 *  Return               :	E_SM_INPUTS_ST
 *  Critical/explanation :  No
 **************************************************************/
  E_SM_INPUTS_ST Get_RightTurnButton_State (void)
 {
	static T_UBYTE lub_counter_RightTurnButton = 0;
	E_SM_INPUTS_ST le_dbnc_RightTurnButton;
	if(ZERO != IO_PinRead(RightTurnButton))
	{
		lub_counter_RightTurnButton ++;
		if(lub_counter_RightTurnButton >= value_set_for_dbnc)
		{
			le_dbnc_RightTurnButton = VALID;
		}
		else
		{
			le_dbnc_RightTurnButton = INVALID;
		}
	}
	else
	{
		lub_counter_RightTurnButton = 0;
		le_dbnc_RightTurnButton = INVALID;
	}
	return le_dbnc_RightTurnButton;
 }
  
 /**************************************************************
 *  Name                 :	Get_SteeringWheel_State
 *  Description          :  Return the state of SteeringWheel
 *  Parameters           :  none
 *  Return               :	E_SM_STWHEEL_ST
 *  Critical/explanation :  No
 **************************************************************/
  E_SM_STWHEEL_ST Get_SteeringWheel_State (void)
 {
	T_UWORD luw_ADC_SWL;
	E_SM_STWHEEL_ST le_adc_swvalue;
	while (!(ADCConvertionComplete())) {};
	luw_ADC_SWL = ADCReadValue(ANS_0);
	if (luw_ADC_SWL > SWLEFT && luw_ADC_SWL < SWRIGHT)
	{
		le_adc_swvalue = SWL_CENTER;
	}
	else if (luw_ADC_SWL < SWLEFT)
	{
		le_adc_swvalue = SWL_LEFT;
	}
	else if (luw_ADC_SWL > SWRIGHT)
	{
		le_adc_swvalue = SWL_RIGHT;
	}
	else
	{
	}
	
	return le_adc_swvalue;
 }
  
 /**************************************************************
 *  Name                 :	Get_StopButton_State
 *  Description          :  Return the state of StopButton
 *  Parameters           :  none
 *  Return               :	E_SM_INPUTS_ST
 *  Critical/explanation :  No
 **************************************************************/
  E_SM_INPUTS_ST Get_StopButton_State (void)
 {
	static T_UBYTE lub_counter_StopButton = 0;
	E_SM_INPUTS_ST le_dbnc_StopButton;
	if(ZERO != IO_PinRead(StopButton))
	{
		lub_counter_StopButton ++;
		if(lub_counter_StopButton >= value_set_for_bdnc)
		{
			le_dbnc_StopButton = VALID;
		}
		else
		{
			le_dbnc_StopButton = INVALID;
		}
	}
	else
	{
		lub_counter_StopButton = 0;
		le_dbnc_StopButton = INVALID;
	}
	return le_dbnc_StopButton;
 }
  
 /**************************************************************
 *  Name                 :	Get_EmergencyLightsButton_State
 *  Description          :  Return the state of EmergencyLightsButton
 *  Parameters           :  none
 *  Return               :	E_SM_INPUTS_ST
 *  Critical/explanation :  No
 **************************************************************/
  E_SM_INPUTS_ST Get_EmergencyLightsButton_State (void)
 {
	static T_UBYTE lub_counter_EmergencyLightsButton = 0;
	E_SM_INPUTS_ST le_dbnc_EmergencyLightsButton;
	if(ZERO != IO_PinRead(EmergencyLightsButton))
	{
		lub_counter_EmergencyLightsButton ++;
		if(lub_counter_EmergencyLightsButton >= value_set_for_bdnc)
		{
			le_dbnc_EmergencyLightsButton = VALID;
		}
		else
		{
			le_dbnc_EmergencyLightsButton = INVALID;
		}
	}
	else
	{
		lub_counter_EmergencyLightsButton = 0;
		le_dbnc_EmergencyLightsButton = INVALID;
	}
	return le_dbnc_EmergencyLightsButton;
 }
  
 /**************************************************************
 *  Name                 :	Get_ReverseSwitch_State
 *  Description          :  Return the state of ReverseSwitch
 *  Parameters           :  none
 *  Return               :	E_SM_INPUTS_ST
 *  Critical/explanation :  No
 **************************************************************/
  E_SM_INPUTS_ST Get_ReverseSwitch_State (void)
 {
	static T_UBYTE lub_counter_ReverseSwitch = 0;
	E_SM_INPUTS_ST le_dbnc_ReverseSwitch;
	if(ZERO != IO_PinRead(ReverseSwitch))
	{
		lub_counter_ReverseSwitch ++;
		if(lub_counter_ReverseSwitch >= value_set_for_bdnc)
		{
			le_dbnc_ReverseSwitch = VALID;
		}
		else
		{
			le_dbnc_ReverseSwitch = INVALID;
		}
	}
	else
	{
		lub_counter_ReverseSwitch = 0;
		le_dbnc_ReverseSwitch = INVALID;
	}
	return le_dbnc_ReverseSwitch;
 }
  
 /**************************************************************
 *  Name                 :	Get_IgnitionSwitch_State
 *  Description          :  Return the state of IgnitionSwitch
 *  Parameters           :  none
 *  Return               :	E_SM_INPUTS_ST
 *  Critical/explanation :  No
 **************************************************************/
  E_SM_INPUTS_ST Get_IgnitionSwitch_State (void)
 {
	static T_UBYTE lub_counter_IgnitionSwitch = 0;
	E_SM_INPUTS_ST le_dbnc_IgnitionSwitch;
	if(ZERO != IO_PinRead(IgnitionSwitch))
	{
		lub_counter_IgnitionSwitch ++;
		if(lub_counter_IgnitionSwitch >= value_set_for_bdnc)
		{
			le_dbnc_IgnitionSwitch = VALID;
		}
		else
		{
			le_dbnc_IgnitionSwitch = INVALID;
		}
	}
	else
	{
		lub_counter_IgnitionSwitch = 0;
		le_dbnc_IgnitionSwitch = INVALID;
	}
	return le_dbnc_IgnitionSwitch;
 }
  
 /**************************************************************
 *  Name                 :	Get_HeadlightsBeamModeBtn_State
 *  Description          :  Return the state of HeadlightsBeamModeBtn
 *  Parameters           :  none
 *  Return               :	E_SM_INPUTS_ST
 *  Critical/explanation :  No
 **************************************************************/
  E_SM_INPUTS_ST Get_HeadlightsBeamModeBtn_State (void)
 {
	static T_UBYTE lub_counter_HeadlightsBeamModeBtn = 0;
	E_SM_INPUTS_ST le_dbnc_HeadlightsBeamModeBtn;
	if(ZERO != IO_PinRead(HeadlightsBeamModeBtn))
	{
		lub_counter_HeadlightsBeamModeBtn ++;
		if(lub_counter_HeadlightsBeamModeBtn >= value_set_for_bdnc)
		{
			le_dbnc_HeadlightsBeamModeBtn = VALID;
		}
		else
		{
			le_dbnc_HeadlightsBeamModeBtn = INVALID;
		}
	}
	else
	{
		lub_counter_HeadlightsBeamModeBtn = 0;
		le_dbnc_HeadlightsBeamModeBtn = INVALID;
	}
	return le_dbnc_HeadlightsBeamModeBtn;
 }
  
 /**************************************************************
 *  Name                 :	Get_HeadlightsContinuousModeBtn_State
 *  Description          :  Return the state of HeadlightsContinuousModeBtn
 *  Parameters           :  none
 *  Return               :	E_SM_INPUTS_ST
 *  Critical/explanation :  No
 **************************************************************/
  E_SM_INPUTS_ST Get_HeadlightsContinuousModeBtn_State (void)
 {
	static T_UBYTE lub_counter_HeadlightsContinuousModeBtn = 0;
	E_SM_INPUTS_ST le_dbnc_HeadlightsContinuousModeBtn;
	if(ZERO != IO_PinRead(HeadlightsContinuousModeBtn))
	{
		lub_counter_HeadlightsContinuousModeBtn ++;
		if(lub_counter_HeadlightsContinuousModeBtn >= value_set_for_bdnc)
		{
			le_dbnc_HeadlightsContinuousModeBtn = VALID;
		}
		else
		{
			le_dbnc_HeadlightsContinuousModeBtn = INVALID;
		}
	}
	else
	{
		lub_counter_HeadlightsContinuousModeBtn = 0;
		le_dbnc_HeadlightsContinuousModeBtn = INVALID;
	}
	return le_dbnc_HeadlightsContinuousModeBtn;
 }
 